#ifndef OMG_DDS_SUB_DATA_READER_LISTENER_HPP_
#define OMG_DDS_SUB_DATA_READER_LISTENER_HPP_

/* Copyright (c) 2009-2010, Real-Time Innovations, Inc.
 * Copyright (c) 2010, Object Management Group, Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * - Redistributions of source code must retain the above copyright notice,
 *   this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the distribution.
 * - Neither the names of the above copyright holders nor the names of their
 *   contributors may be used to endorse or promote products derived from
 *   this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL A COPYRIGHT HOLDER OR CONTRIBUTOR BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */


namespace dds { namespace sub {

template <typename T>
class DataReaderListener : public virtual dds::core::Listener {
protected:
    DataReaderListener();
    DataReaderListener(const DataReaderListener& src);
    DataReaderListener& operator=(const DataReaderListener& src);

public:
    virtual ~DataReaderListener();

public:
    virtual void on_requested_deadline_missed(
            const DataReader<T>& the_reader,
            const RequestedDeadlineMissedStatus& status) = 0;

    virtual void on_requested_incompatible_qos(
            const DataReader<T>& the_reader,
            const RequestedIncompatibleQosStatus& status) = 0;

    virtual void on_sample_rejected(
            const DataReader<T>& the_reader,
            const SampleRejectedStatus& status) = 0;

    virtual void on_liveliness_changed(
            const DataReader<T>& the_reader,
            const LivelinessChangedStatus& status) = 0;

    virtual void on_data_available(const DataReader<T>& the_reader) = 0;

    virtual void on_subscription_matched(
            const DataReader<T>& the_reader,
            const SubscriptionMatchedStatus& status) = 0;

    virtual void on_sample_lost(
            const DataReader<T>& the_reader,
            const SampleLostStatus& status) = 0;
};


template <typename T>
class NoOpDataReaderListener : public DataReaderListener<T> {
public:
    NoOpDataReaderListener();
    NoOpDataReaderListener(const NoOpDataReaderListener& src);
    virtual ~NoOpDataReaderListener();

public:
    virtual void on_requested_deadline_missed(
            const DataReader<T>& the_reader,
            const RequestedDeadlineMissedStatus& status);

    virtual void on_requested_incompatible_qos(
            const DataReader<T>& the_reader,
            const RequestedIncompatibleQosStatus& status);

    virtual void on_sample_rejected(
            const DataReader<T>& the_reader,
            const SampleRejectedStatus& status);

    virtual void on_liveliness_changed(
            const DataReader<T>& the_reader,
            const LivelinessChangedStatus& status);

    virtual void on_data_available(const DataReader<T>& the_reader);

    virtual void on_subscription_matched(
            const DataReader<T>& the_reader,
            const SubscriptionMatchedStatus& status);

    virtual void on_sample_lost(
            const DataReader<T>& the_reader,
            const SampleLostStatus& status);
};


class BaseDataReaderListener : public virtual dds::core::Listener {
protected:
    BaseDataReaderListener();
    BaseDataReaderListener(const BaseDataReaderListener&);
    BaseDataReaderListener& operator=(const BaseDataReaderListener&);

public:
    virtual ~BaseDataReaderListener();

public:
    virtual void on_requested_deadline_missed(
            const DataReaderBase& the_reader,
            const RequestedDeadlineMissedStatus& status) = 0;

    virtual void on_requested_incompatible_qos(
            const DataReaderBase& the_reader,
            const RequestedIncompatibleQosStatus& status) = 0;

    virtual void on_sample_rejected(
            const DataReaderBase& the_reader,
            const SampleRejectedStatus& status) = 0;

    virtual void on_liveliness_changed(
            const DataReaderBase& the_reader,
            const LivelinessChangedStatus& status) = 0;

    virtual void on_data_available(const DataReaderBase& the_reader) = 0;

    virtual void on_subscription_matched(
            const DataReaderBase& the_reader,
            const SubscriptionMatchedStatus& status) = 0;

    virtual void on_sample_lost(
            const DataReaderBase& the_reader,
            const SampleLostStatus& status) = 0;
};


class NoOpBaseDataReaderListener : public BaseDataReaderListener {
public:
    NoOpBaseDataReaderListener();
    NoOpBaseDataReaderListener(const NoOpBaseDataReaderListener&);
    virtual ~NoOpBaseDataReaderListener();

public:
    virtual void on_requested_deadline_missed(
            const DataReaderBase& the_reader,
            const RequestedDeadlineMissedStatus& status);

    virtual void on_requested_incompatible_qos(
            const DataReaderBase& the_reader,
            const RequestedIncompatibleQosStatus& status);

    virtual void on_sample_rejected(
            const DataReaderBase& the_reader,
            const SampleRejectedStatus& status);

    virtual void on_liveliness_changed(
            const DataReaderBase& the_reader,
            const LivelinessChangedStatus& status);

    virtual void on_data_available(const DataReaderBase& the_reader);

    virtual void on_subscription_matched(
            const DataReaderBase& the_reader,
            const SubscriptionMatchedStatus& status);

    virtual void on_sample_lost(
            const DataReaderBase& the_reader,
            const SampleLostStatus& status);
};

} }

#endif /* OMG_DDS_SUB_DATA_READER_LISTENER_HPP_ */
